﻿using System;
using Framework;
namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 修改产品
    /// </summary>
    public partial class EditProduct : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var id = Fq("CoProductId").SafeToInt();
                var name = Fq("CoName").SafeToString();
                var nameEn = Fq("CoNameEn");
                var description = Fq("CoDescription").SafeToString();
                var descriptionEn = Fq("CoDescriptionEn").SafeToString();
                var productCategoryId = Fq("CoProductCategoryId").SafeToInt();
                var coverProductImageId = Fq("CoCoverImageId").SafeToInt();
                var isRecommend = Fq("CoIsRecommend").SafeToBool();
                var model = Fq("CoModel").SafeToString();
                string keyword = Fq("CoKeyword").SafeToString(),
                    keywordEn = Fq("CoKeywordEn").SafeToString(),
                    finish = Fq("CoFinish").SafeToString(),
                    finishEn = Fq("CoFinishEn").SafeToString(),
                    material = Fq("CoMaterial").SafeToString(),
                    materialEn = Fq("CoMaterialEn").SafeToString(),
                    doorThickness = Fq("CoDoorThickness").SafeToString(),
                    backset = Fq("CoBackset").SafeToString(),
                    availableFor = Fq("CoAvailableFor").SafeToString(),
                    availableForEn = Fq("CoAvailableForEn").SafeToString(),
                    applicableStandard = Fq("CoApplicableStndard").SafeToString(),
                        size = Fq("CoSize").SafeToString(),
                        modelEn = Fq("CoModelEn").SafeToString();
                var summary = Fq("CoSummary").SafeToString();
                var summaryEn = Fq("CoSummaryEn").SafeToString();
                var productService = new ProductService();
                productService.Edit(id, name, nameEn, productCategoryId, description, descriptionEn, model, isRecommend, coverProductImageId, keyword, keywordEn, finish, finishEn, material, materialEn, doorThickness, backset, availableFor, availableForEn, applicableStandard, size, modelEn, summary, summaryEn);
                result = new { state = true, message = "修改成功" };
            }
            catch (Exception ex)
            {
                result = new { state = false, message = ex.Message };
            }
            Json(result);
        }
    }
}